import request from '@/axios/request';

// 原有的API接口
export function getContracts() {
  return request({
    url: '/item-brand/contracts',
    method: 'get'
  });
}

export function getPickingIds(params: { contract_no: string }) {
  return request({
    url: '/item-brand/picking-ids',
    method: 'get',
    params
  });
}

export function getBillData(params: { contract_no: string; picking_id: string }) {
  return request({
    url: '/item-brand/bill-data',
    method: 'get',
    params
  });
}

export function getBrandModel(params: { material_code: string }) {
  return request({
    url: '/item-brand/brand-model',
    method: 'get',
    params: {
      item: params.material_code
    }
  });
}

export function submitBillData(data: any) {
  return request({
    url: '/item-brand/submit',
    method: 'post',
    data
  });
}

// 临时品牌型号数据API
export function getTempBrandModels(params: { 
  contract_no: string; 
  picking_id: string;
}) {
  return request({
    url: `/api/temp-brand-models/${params.contract_no}/${params.picking_id}`,
    method: 'get'
  });
}

export function saveTempBrandModel(data: {
  contract_no: string;
  picking_id: string;
  material_code: string;
  brand: string;
  model: string;
  specification: string;
  origin: string;
  quantity: number;
}) {
  return request({
    url: '/api/temp-brand-models',
    method: 'post',
    data
  });
}

export function deleteTempBrandModels(params: { 
  contract_no: string; 
  picking_id: string;
}) {
  return request({
    url: `/api/temp-brand-models/${params.contract_no}/${params.picking_id}`,
    method: 'delete'
  });
}

export function deleteTempBrandModelById(id: number) {
  return request({
    url: `/api/temp-brand-models/id/${id}`,
    method: 'delete'
  });
}

/**
 * 获取需要拍照的物料列表
 */
export const getPhotoRequiredItems = (params: { contract_no: string }) => {
  return request({
    url: '/item-brand/photo-required-items',
    method: 'get',
    params
  });
};

// 删除上传照片的API，因为改为前端本地保存
// /**
//  * 上传物料照片
//  */
// export const uploadItemPhoto = (formData: FormData) => {
//   return request({
//     url: '/item-brand/upload-photo',
//     method: 'post',
//     data: formData,
//     headers: {
//       'Content-Type': 'multipart/form-data'
//     }
//   });
// }; 